Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paginated users list in notifications and usergroups #477

Closed

Conversation

indralukmana
Copy link

This PR address the issue #450

The enhancement affects two modules: notifications and user-groups. In notifications, the users list is used to notify users on a post. In user-groups, the users list is used to modify usergroups membership.

I made/modify ajax endpoints in notifications.php and user-groups.php. The endpoints are mainly used to get users list in parts and to handle user saving.

Ajax endpoints:

  • notifications.php
    • ajax_retrieve_users()
    • ajax_save_post_subscriptions() (modified how users saved)
  • user-groups.php
    • ajax_retrieve_users_in_usergroups()
    • ajax_save_user_to_usergroup

The users list are created with a template users_list() in class_module.php. The DOM in the template then modified in notifications.js and user-groups.js. The ajax calls are also done in these two files.

Screenshots for the changes:

old notifications
notifications - old

new notifications
notifications - new

old usergroups
usergroups - old

new usergroups
usergroups - new

Add lib for user list features. http://listjs.com/
Turned off the users saved in user-groups. Making '$users' parameter in update_usergroup function default to null
In this commit the users list is redefined using list.js and twbsPagination. Mainly using DOM modification triggered by ajax calls.
The users list template should be able to be accessed in notifications and user-groups. In class-module this can be done.
put a check on the javascript so it only run on post creation/edit
put check on user-groups.js so the javascript only run on user-groups
Made a new separate function for adding and removing user to notification. Revert changes made to save_post_following_users() function to prevent breaking other codes.
Put a total user count in hidden field inside the users list template. This then can be used to initialize users list in notifications.php and user-groups.php. Eliminating the need to do ajax request to initialize the users list.
Split the counts logic to its own separate function for code clarity and performance. The ajax_retrieve_users() which called everytime users page repopulated now use get_users() which doesn't include total_count.
Split the logic for retrieving users count into its own ajax endpoint. The function ajax_retrieve_users_in_usergroups() now use get_users() which is more performant as it does note do total_count. So when doing search by keyword we only do total users calculation by keyword only once, in the beginning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants